package com.singzi.leetcode.jianzhiOffer2;

import java.util.ArrayList;
import java.util.List;

public class T0079 {
    public static void main(String[] args) {
        int []a ={1,2,3};
        Solution0079 solution0079 = new Solution0079();
        System.out.println(solution0079.subsets(a));
    }
}
class Solution0079 {
    List<List<Integer>> ans;
    public List<List<Integer>> subsets(int[] nums) {
        ans = new ArrayList<>();
        List<Integer> temp = new ArrayList<>();
        backTrace(nums, 0, temp);
        return ans;
    }
    public void backTrace(int[]nums, int index, List<Integer> temp){
        ans.add(new ArrayList<>(temp));

        for(int i = index;i < nums.length;i++){
            temp.add(nums[index]);
            backTrace(nums, i+1, temp);
            temp.remove(temp.size()-1);
        }
    }
}
